/*
 * @Author : Genustin
 * @Date   : 2012-06-26
 * 求肿瘤面积, 矩阵中0代表肿瘤，边缘规则，与矩阵边缘齐平
 */
#include <iostream>
using namespace std;

int main()
{
	int psize;
	int row, col, edge;
	int pix;
	row  = 0;
	edge = 0;
	cin >> psize;
	for (size_t i = 0; i < psize; ++i) 
	{
		col = 0;
		for(size_t j = 0; j < psize; ++j) 
		{
			cin >> pix;
			if(pix == 0)
				++col;
		}
		if(col > 0)
		{
			++row;
			edge += col;
		}
	}
	cout << row*(edge-2*row+4)/2 - edge << endl;	
	return 0;
}
